<?php
namespace Decorator\Concrete;

include_once "DecoratorInterface.php";

use Decorator\DecoratorInterface;
/** 装饰抽象类 */
class AbstractDecorator implements DecoratorInterface
{
    /** @var DecoratorInterface 存储具体装饰类对象 */
    public DecoratorInterface $decoratorObject;

    /**
     * 设置具体装饰对象
     * @param DecoratorInterface $object
     */
    public function setDecoratorObject(DecoratorInterface $object)
    {
        $this->decoratorObject = $object;
    }

    public function operation()
    {
        if (!is_null($this->decoratorObject)) {
            $this->decoratorObject->operation();
        }
    }
}